Skip to content

Implement curl KeepAlive for watch connections #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hirishh
Copy link
Contributor

@hirishh hirishh commented Jul 15, 2025

Hello,

I've implemented a simple way to enable keepalive as suggested in #202 (comment)

I'm activating it only if "watch=1" is passed as queryParameters and keepalive is enabled in the clientApi configuration.
If you want this to be different, please advice, and I will change the implementation.

I've tested it with watch_list_pod example and using wireshark:

keepalive

Best,

hirishh

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hirishh
Once this PR has been reviewed and has the lgtm label, please assign brendandburns for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested a review from ityuhui July 15, 2025 09:37
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 15, 2025
@brendandburns
Copy link
Contributor

Unfortunately, all of this code is generated, which means that the next time we regenerate, this change will be overridden.

The right place to fix this is in the generator itself:

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/C-libcurl/apiClient.h.mustache
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/C-libcurl/apiClient.c.mustache

They've generally been really good about merging PRs relatively quickly.

Once the generator is updated, we can regenerate the code to pick up the change.

Sorry for the complexity, but generated code is the only way we can keep up with the very large surface area of the Kubernetes API.

@brendandburns
Copy link
Contributor

I also suspect that they won't accept the isWatchCall part since it is very kubernetes specific. I think the right thing to do is probably to implement a watch function or some-such that creates a separate API client and sets the config to do keepAlive. I'll leave it to you to figure out the approach that you like best.

@hirishh
Copy link
Contributor Author

hirishh commented Jul 15, 2025

Thank you for the information. I will try to do a PR there.

Honestly, I believe there is no need to do a check like "isWatchCall". Activating the keepalive has no consequences for normal calls.

@brendandburns
Copy link
Contributor

If the upstream code generator is ok to merge it without the check, we'll pick it up from there.

Thanks! (and apologies again for the complication)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants